import unittest
from interfaceFramework.funcDemo.CaleDemo import Cale
from interfaceFramework.funcDemo.Sjx import Sjx
from interfaceFramework.Commonlib.ReadXml import readXml
from interfaceFramework.Commonlib.ReadCsv import ReadCsv
# 读取xml 文件
rx = readXml()
# a = int(r.read_xml("../DataXml/data.xml","sum","num1"))
# b = int(r.read_xml("../DataXml/data.xml","sum","num2"))
# sum = int(r.read_xml("../DataXml/data.xml","sum","expect"))
# 读取csv文件
rc = ReadCsv()


class Test1(unittest.TestCase):
    #初始化函数
    def setUp(self):
        print("start")

    # 结束函数
    def tearDown(self) -> None:
        print("end")

    def test001(self):
        ca =  Cale()
        res1 = ca.sum(int(rx.read_xml("../DataXml/data.xml","sum","num1")),
                      int(rx.read_xml("../DataXml/data.xml","sum","num2")))
        self.assertEqual(res1,int(rx.read_xml("../DataXml/data.xml","sum","expect")))

    def test002(self):
        ca = Cale()
        ret2 = ca.jian(int(rx.read_xml("../DataXml/data.xml","jian","num1")),
                      int(rx.read_xml("../DataXml/data.xml","jian","num2")))
        self.assertEqual(ret2,int(rx.read_xml("../DataXml/data.xml","jian","expect")))
    def test003(self):
        ca = Sjx()
        my_list = rc.read_csv("../DataXml/sjx.csv")
        for ml in my_list:
            rel = ca.sjxpd(int(ml[0]),int(ml[1]),int(ml[2]))
            self.assertEqual(rel,int(ml[3]))


if __name__ == '__main__':
    unittest.main()